package com.cn.Api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.client.RestTemplate;

import java.util.Vector;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class CountDownLatchTest1 implements Runnable{

    final AtomicInteger number = new AtomicInteger();
    volatile boolean bol = false;


    @Override
    public void run() {

        RestTemplate restTemplate=new RestTemplate();
        System.out.println(number.getAndIncrement());
        Lock lock = new ReentrantLock();
        synchronized (this) {
            try {
                if (!bol) {
                    System.out.println(bol);
                    bol = true;
                    Thread.sleep(10000);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            restTemplate.getForObject("127.0.0.1//web/test1",String.class);
            System.out.println("并发数量为" + number.intValue());
        }

    }

    public static void main(String[] args) {


    }
}
